Skip to content

Fix issue 563#1958

Open
KyWB wants to merge 3 commits into
session-foundation:devfrom
KyWB:fix-issue-563
Open

Fix issue 563#1958
KyWB wants to merge 3 commits into
session-foundation:devfrom
KyWB:fix-issue-563

Conversation

@KyWB

@KyWB KyWB commented Jun 28, 2026

Copy link
Copy Markdown

First time contributor checklist:

Contributor checklist:

Description

Fixes #563 — ONS names entered into the Add Moderator/Admin dialog were
immediately rejected with "This Account ID is invalid" instead of being
resolved to their corresponding 66-character hex public key.

Root cause: ModeratorsAddDialog.tsx validated input directly via
PubKey.from() with no prior ONS resolution step. The ONS resolver
(ONSResolve.getSessionIDForOnsName) already existed and was used by the
New Message flow (OverlayMessage.tsx), but was never called from the
moderator dialog.

What this PR does:

  • Extracts a new shared helper resolvePubkeyOrOns() in
    ts/session/utils/resolvePubkeyOrOns.ts that encapsulates the full
    resolution ladder: trim/normalize -> pass through valid non-blinded 05
    pubkeys -> reject blinded/03-group keys -> ONS regex gate -> network
    resolve -> re-validate. Returns a discriminated union and never throws.
  • Updates ModeratorsAddDialog.tsx to resolve each comma-separated entry
    through the shared helper before submission. Shows a spinner and disables
    the Add button during resolution. Surfaces failures inline via
    providedError rather than only a generic toast. Multi-add inputs name
    the specific failing entry.
  • Refactors OverlayMessage.tsx (New Message flow) onto the same shared
    helper, collapsing ~45 lines of inline resolution logic into a single
    call. Behavior is fully preserved.
  • Updates the Add Admins placeholder copy from accountId to
    accountIdOrOnsEnter so the dialog advertises ONS support.

Test approach:

  • 11 new unit tests in ts/test/session/unit/utils/resolvePubkeyOrOns_test.ts
    covering: valid pubkey passthrough, whitespace trim, blinded key rejection,
    03-group key rejection, empty input, successful ONS resolution, dotted-name
    rejection, NotFoundError mapping, SnodeResponseError mapping, generic error
    mapping, and resolved-but-invalid-id handling.
  • Full test suite: 919 passing, 0 failures.
  • Manual testing on Windows 11 with SESSION_DEV=1: entering a valid ONS
    name in Add Admins now triggers async resolution; valid hex pubkeys still
    work unchanged; invalid inputs still show appropriate errors.
  • OS: Windows 11

KyWB and others added 3 commits June 10, 2026 18:32
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…tion#563)

- Extract shared resolvePubkeyOrOns() helper
- ModeratorsAddDialog: async ONS resolution before submit, inline errors, spinner
- OverlayMessage: refactored onto shared resolver (~45 lines collapsed to one call)
- Add 11 unit tests covering all resolver paths
@KyWB

KyWB commented Jun 28, 2026

Copy link
Copy Markdown
Author

Hi! This is my first contribution to Session Desktop. I've addressed issue #563
by extracting a shared ONS resolver and wiring it into the moderator add dialog. Would appreciate a review when you have time!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Resolve ONS anywhere we accept a Session ID

1 participant